package cn.mastor.basic.controller;

import cn.mastor.basic.domain.AccountLogin;
import cn.mastor.basic.domain.WechatLoginDto;
import cn.mastor.basic.service.ILoginService;
import cn.mastor.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;
    @PostMapping("/account")
    public AjaxResult emplogin(@RequestBody AccountLogin accountLogin){
        Map<String, Object> stringObjectMap = loginService.accountLogin(accountLogin);
//        System.out.println(user);
        return AjaxResult.me().success(stringObjectMap);
    }

    @PostMapping("/wechat")
    public AjaxResult wxlogin(@RequestBody WechatLoginDto dto){
        return loginService.wechatLogin(dto);
    }

    @PostMapping("/wechat/binder")
    public AjaxResult wxbinder(@RequestBody WechatLoginDto dto){
        return AjaxResult.me().success(loginService.wechatBinder(dto));
    }
}
